package c.c.b.a.b.a.j;

import c.c.b.a.a.l;
import c.c.b.a.a.o;
import c.c.b.a.a.r;
import c.c.b.a.a.x;
import c.c.b.a.b.a.e;
import com.pgl.sys.ces.out.ISdkLite;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;

/* compiled from: PublicSuffixDatabase */
public final class a {
    public static final byte[] e = new byte[]{(byte) 42};
    public static final String[] f = new String[0];
    public static final String[] g = new String[]{"*"};
    public static final a h = new a();
    public final AtomicBoolean a = new AtomicBoolean(false);
    public final CountDownLatch b = new CountDownLatch(1);
    public byte[] c;
    public byte[] d;

    public static String a(byte[] bArr, byte[][] bArr2, int i) {
        byte[] bArr3 = bArr;
        byte[][] bArr4 = bArr2;
        int length = bArr3.length;
        int i2 = 0;
        while (i2 < length) {
            int i3;
            int i4 = (i2 + length) / 2;
            while (i4 > -1 && bArr3[i4] != (byte) 10) {
                i4--;
            }
            i4++;
            int i5 = 1;
            while (true) {
                i3 = i4 + i5;
                if (bArr3[i3] == (byte) 10) {
                    break;
                }
                i5++;
            }
            int i6 = i3 - i4;
            int i7 = i;
            Object obj = null;
            int i8 = 0;
            int i9 = 0;
            while (true) {
                Object obj2;
                if (obj != null) {
                    i5 = 46;
                    obj2 = null;
                } else {
                    obj2 = obj;
                    i5 = bArr4[i7][i8] & ISdkLite.REGION_UNSET;
                }
                i5 -= bArr3[i4 + i9] & ISdkLite.REGION_UNSET;
                if (i5 == 0) {
                    i9++;
                    i8++;
                    if (i9 == i6) {
                        break;
                    } else if (bArr4[i7].length != i8) {
                        obj = obj2;
                    } else if (i7 == bArr4.length - 1) {
                        break;
                    } else {
                        i7++;
                        obj = 1;
                        i8 = -1;
                    }
                } else {
                    break;
                }
            }
            if (i5 >= 0) {
                if (i5 <= 0) {
                    int i10 = i6 - i9;
                    i5 = bArr4[i7].length - i8;
                    while (true) {
                        i7++;
                        if (i7 >= bArr4.length) {
                            break;
                        }
                        i5 += bArr4[i7].length;
                    }
                    if (i5 >= i10) {
                        if (i5 <= i10) {
                            return new String(bArr3, i4, i6, e.j);
                        }
                    }
                }
                i2 = i3 + 1;
            }
            length = i4 - 1;
        }
        return null;
    }

    public final void b() throws IOException {
        InputStream resourceAsStream = a.class.getResourceAsStream("publicsuffixes.gz");
        if (resourceAsStream != null) {
            byte[] xVar = new x();
            r rVar = new r(new l(o.b(resourceAsStream, xVar)));
            try {
                byte[] bArr = new byte[rVar.j()];
                rVar.k(bArr);
                xVar = new byte[rVar.j()];
                rVar.k(xVar);
                synchronized (this) {
                    this.c = bArr;
                    this.d = xVar;
                }
                this.b.countDown();
            } finally {
                e.n(rVar);
            }
        }
    }
}
